class CameraController {
    constructor(man) {
        this.man = man;

        this.x = -1;
        this.y = -1;
        this.axisY = new THREE.Vector3(0,1,0);
    }

    update(){
        let that = this;

        window.addEventListener('mousemove',function (e) {

            let man = that.man;

            let deltaX = e.movementX;
            let deltaY = e.movementY;

            man.rotateOnWorldAxis(that.axisY,deltaX/500);
            man.rotateX(-deltaY/1000);

            that.x = e.clientX;
            that.y = e.clientY;
        });

        window.addEventListener('click', function () {
            that.lockPointer();
        });

    }

    lockPointer() {
        window.document.body.requestPointerLock();
    }

}